# @Author   : 懒羊羊
# @File     : homeWk_24_11_27.py
# @Time     : 2024/11/27 18:32

# 8、将元组（90,30,99,89,50,70,60,60,40,50,60）去重并从小到大排序（使用冒泡排序）。
# tuple1 = (90, 30, 99, 89, 50, 70, 60, 60, 40, 50, 60)
# set1 = set(tuple1)
# mylist = list(set1)
# print(mylist)
# for i in range(0, len(mylist) - 1):
#     for j in range(0, len(mylist) - 1 - i):
#         if mylist[j] > mylist[j + 1]:
#             mylist[j], mylist[j + 1] = mylist[j + 1], mylist[j]
#
# print(mylist)
# 9、使用列表推导式分别生成，1~500的5的倍数，1-500的偶数自加5，1到100之间偶数*2，奇数*3
# l1 = [i for i in range(0, 501, 5)]
# print(l1)
#
# l2 = [i + 5 for i in range(1, 501) if i % 2 == 0]
# print(l2)
#
# l3 = [i * 2 if i % 2 == 0 else i * 3 for i in range(1, 101)]
# print(l3)

# 16、通过键盘获取两个数，用三元表达式赋值法将最小值赋给变量：iMin
# num1 = int(input("请输入第一个数字："))
# num2 = int(input("请输入第二个数字："))
# iMin = num1 if num1 > num2 else num2
# print(iMin)


# 13、定义一个形参类型分别是必填项字符串1、，选填字符串2，不定长元组、不定长字典的函数，分别打印出该字符串、元组内容，字典的值
# 分别调用该函数：参数是仅必填项、  必填+选填、不定长元组、不定长字典
# def my_function(a, b="456", *args, **kwargs):
#     print(f"字符串1内容是：{a}，字符串2内容是：{b}，元组内容是：{args}，字典的值：{kwargs}")
#
#
# my_function("123")
# my_function("123", "789")
# my_function("123", "654", 9, 8, 7, )
# my_function("123", "654", name='懒羊羊', age=22)


# 15：题目10中的加、减、乘、除 分别定义成匿名函数，去调用

# jia = lambda a, b: a + b
# print(jia(4, 5))
#
# jian = lambda a, b: a - b
# print(jian(9, 6))
#
# cheng = lambda a, b: a * b
# print(cheng(3, 9))
#
# chu = lambda a, b: a / b
# print(chu(15, 3))


# 16、分别定义加、减、乘、除 普通函数，并分别调用
#
# def jia(num1, num2):
#     return num1 + num2
#
#
# def jian(num1, num2):
#     return num1 - num2
#
#
# def cheng(num1, num2):
#     return num1 * num2
#
#
# def chu(num1, num2):
#     return num1 / num2
#
#
# print(jia(4, 5))
# print(jian(12, 6))
# print(cheng(6, 6))
# print(chu(65, 5))

# 17、给16题中的函数增加运算前的说明，运算后的说明
def my_decorator(funct):
    def wrapper(*args, **kwargs):
        print("开始计算了！！！")
        result = funct(*args, **kwargs)
        print("计算结束了！！！")
        return result

    return wrapper
j

@my_decorator
def jia(num1, num2):
    return num1 + num2


@my_decorator
def jian(num1, num2):
    return num1 - num2


@my_decorator
def cheng(num1, num2):
    return num1 * num2


@my_decorator
def chu(num1, num2):
    return num1 / num2


a = jia(6, 6)
print(a)
# b = jian(15, 5)
# print(b)
# c = cheng(8, 8)
# print(c)
# d = chu(26, 4)
# print(d)
